@@ -0,0 +1,23 @@ |
||
1 |
+# Generated by Django 2.2.15 on 2021-08-16 02:54 |
|
2 |
+ |
|
3 |
+from django.db import migrations, models |
|
4 |
+ |
|
5 |
+ |
|
6 |
+class Migration(migrations.Migration): |
|
7 |
+ |
|
8 |
+ dependencies = [ |
|
9 |
+ ('account', '0002_userinfo'), |
|
10 |
+ ] |
|
11 |
+ |
|
12 |
+ operations = [ |
|
13 |
+ migrations.AlterField( |
|
14 |
+ model_name='administratorinfo', |
|
15 |
+ name='status', |
|
16 |
+ field=models.BooleanField(db_index=True, default=True, help_text='Status', verbose_name='status'), |
|
17 |
+ ), |
|
18 |
+ migrations.AlterField( |
|
19 |
+ model_name='userinfo', |
|
20 |
+ name='status', |
|
21 |
+ field=models.BooleanField(db_index=True, default=True, help_text='Status', verbose_name='status'), |
|
22 |
+ ), |
|
23 |
+ ] |
@@ -79,10 +79,16 @@ def eqpt_onoff(request): |
||
79 | 79 |
macid = request.POST.get('macid', '') |
80 | 80 |
active = request.POST.get('active', 0) |
81 | 81 |
|
82 |
- ThermometerEquipmentInfo.objects.update_or_create(macid=macid, defaults={ |
|
83 |
- 'active_status': active, |
|
84 |
- 'active_at': tc.utc_datetime(), |
|
85 |
- }) |
|
82 |
+ eqpt = ThermometerEquipmentInfo.objects.get(macid=macid) |
|
83 |
+ eqpt.active_status = active |
|
84 |
+ eqpt.active_at = tc.utc_datetime() |
|
85 |
+ eqpt.save() |
|
86 |
+ |
|
87 |
+ if active == 0: |
|
88 |
+ user = IsolationPointUserInfo.objects.get(pk=eqpt.ipui_pk) |
|
89 |
+ user.status = False |
|
90 |
+ user.leave_at = tc.utc_datetime() |
|
91 |
+ user.save() |
|
86 | 92 |
|
87 | 93 |
return response() |
88 | 94 |
|
@@ -92,9 +98,14 @@ def eqpt_remark(request): |
||
92 | 98 |
macid = request.POST.get('macid', '') |
93 | 99 |
remark = request.POST.get('remark', '') |
94 | 100 |
|
95 |
- ThermometerEquipmentInfo.objects.update_or_create(macid=macid, defaults={ |
|
96 |
- 'remark': remark, |
|
97 |
- }) |
|
101 |
+ eqpt = ThermometerEquipmentInfo.objects.get(macid=macid) |
|
102 |
+ eqpt.remark = remark |
|
103 |
+ eqpt.save() |
|
104 |
+ |
|
105 |
+ # 存放历史备注记录 |
|
106 |
+ user = IsolationPointUserInfo.objects.get(pk=eqpt.ipui_pk) |
|
107 |
+ user.remark += [remark] |
|
108 |
+ user.save() |
|
98 | 109 |
|
99 | 110 |
return response() |
100 | 111 |
|
@@ -143,7 +154,7 @@ def eqpt_result(request): |
||
143 | 154 |
logs = ThermometerMeasureInfo.objects.filter( |
144 | 155 |
point_id=point_id, |
145 | 156 |
point_measure_ymd=tc.local_string(format='%Y-%m-%d'), |
146 |
- point_measure_window=point.point_measure_window, |
|
157 |
+ point_measure_window=point.previous_measure_window, |
|
147 | 158 |
macid__in=macids, |
148 | 159 |
status=True, |
149 | 160 |
).values('macid', 'temperature') |
@@ -188,7 +199,7 @@ def get_screen_data(point=None, point_id=None): |
||
188 | 199 |
logs = ThermometerMeasureInfo.objects.filter( |
189 | 200 |
point_id=point_id, |
190 | 201 |
point_measure_ymd=tc.local_string(format='%Y-%m-%d'), |
191 |
- point_measure_window=point.point_measure_window, |
|
202 |
+ point_measure_window=point.previous_measure_window, |
|
192 | 203 |
macid__in=macids, |
193 | 204 |
status=True, |
194 | 205 |
).values('macid', 'temperature') |
@@ -6,6 +6,7 @@ from django_logit import logit |
||
6 | 6 |
from django_query import get_query_value |
7 | 7 |
from django_response import response |
8 | 8 |
from paginator import pagination |
9 |
+from TimeConvert import TimeConvert as tc |
|
9 | 10 |
|
10 | 11 |
from equipment.models import IsolationPointInfo, IsolationPointUserInfo, ThermometerEquipmentInfo |
11 | 12 |
from utils.error.errno_utils import IsolationPointStatusCode |
@@ -92,7 +93,10 @@ def bind_eqpt(request): |
||
92 | 93 |
return response(IsolationPointStatusCode.ISOLATIONPOINT_USER_NOT_FOUND) |
93 | 94 |
|
94 | 95 |
ThermometerEquipmentInfo.objects.update_or_create(macid=macid, defaults={ |
96 |
+ 'point_id': ipui.point_id, |
|
95 | 97 |
'ipui_pk': ipui.pk, |
98 |
+ 'active_status': True, |
|
99 |
+ 'active_at': tc.utc_datetime() |
|
96 | 100 |
}) |
97 | 101 |
|
98 | 102 |
return response() |
@@ -0,0 +1 @@ |
||
1 |
+440a5eaf195701404ec0ae4f50adefaf |
@@ -0,0 +1,54 @@ |
||
1 |
+# Generated by Django 2.2.15 on 2021-08-16 02:54 |
|
2 |
+ |
|
3 |
+from django.db import migrations, models |
|
4 |
+import jsonfield.fields |
|
5 |
+ |
|
6 |
+ |
|
7 |
+class Migration(migrations.Migration): |
|
8 |
+ |
|
9 |
+ dependencies = [ |
|
10 |
+ ('equipment', '0008_auto_20210815_1731'), |
|
11 |
+ ] |
|
12 |
+ |
|
13 |
+ operations = [ |
|
14 |
+ migrations.AddField( |
|
15 |
+ model_name='isolationpointuserinfo', |
|
16 |
+ name='leave_at', |
|
17 |
+ field=models.DateTimeField(blank=True, help_text='离开时间', null=True, verbose_name='leave_at'), |
|
18 |
+ ), |
|
19 |
+ migrations.AddField( |
|
20 |
+ model_name='isolationpointuserinfo', |
|
21 |
+ name='remark', |
|
22 |
+ field=jsonfield.fields.JSONField(blank=True, default=[], help_text='备注', null=True, verbose_name='remark'), |
|
23 |
+ ), |
|
24 |
+ migrations.AlterField( |
|
25 |
+ model_name='isolationpointfieldpoolinfo', |
|
26 |
+ name='status', |
|
27 |
+ field=models.BooleanField(db_index=True, default=True, help_text='Status', verbose_name='status'), |
|
28 |
+ ), |
|
29 |
+ migrations.AlterField( |
|
30 |
+ model_name='isolationpointinfo', |
|
31 |
+ name='status', |
|
32 |
+ field=models.BooleanField(db_index=True, default=True, help_text='Status', verbose_name='status'), |
|
33 |
+ ), |
|
34 |
+ migrations.AlterField( |
|
35 |
+ model_name='isolationpointuserinfo', |
|
36 |
+ name='status', |
|
37 |
+ field=models.BooleanField(db_index=True, default=True, help_text='Status', verbose_name='status'), |
|
38 |
+ ), |
|
39 |
+ migrations.AlterField( |
|
40 |
+ model_name='thermometerequipmentinfo', |
|
41 |
+ name='status', |
|
42 |
+ field=models.BooleanField(db_index=True, default=True, help_text='Status', verbose_name='status'), |
|
43 |
+ ), |
|
44 |
+ migrations.AlterField( |
|
45 |
+ model_name='thermometermeasureinfo', |
|
46 |
+ name='status', |
|
47 |
+ field=models.BooleanField(db_index=True, default=True, help_text='Status', verbose_name='status'), |
|
48 |
+ ), |
|
49 |
+ migrations.AlterField( |
|
50 |
+ model_name='thermometermeasureloginfo', |
|
51 |
+ name='status', |
|
52 |
+ field=models.BooleanField(db_index=True, default=True, help_text='Status', verbose_name='status'), |
|
53 |
+ ), |
|
54 |
+ ] |
@@ -118,7 +118,19 @@ class IsolationPointInfo(BaseModelMixin): |
||
118 | 118 |
start_t, end_t = window.get('start'), window.get('end') |
119 | 119 |
start_dt = tc.string_to_utc_datetime(f'{current_ymd} {start_t}:00') |
120 | 120 |
end_dt = tc.string_to_utc_datetime(f'{current_ymd} {end_t}:00') |
121 |
- if tc.utc_datetime(start_dt, minutes=-30) < current_dt < tc.utc_datetime(end_dt, minutes=30): |
|
121 |
+ if tc.utc_datetime(start_dt) < current_dt < tc.utc_datetime(end_dt): |
|
122 |
+ return f'{start_t}-{end_t}' |
|
123 |
+ return '' |
|
124 |
+ |
|
125 |
+ @property |
|
126 |
+ def previous_measure_window(self): |
|
127 |
+ current_ymd = tc.local_string(format='%Y-%m-%d') |
|
128 |
+ current_dt = tc.utc_datetime() |
|
129 |
+ for window in self.point_measure_window: |
|
130 |
+ start_t, end_t = window.get('start'), window.get('end') |
|
131 |
+ start_dt = tc.string_to_utc_datetime(f'{current_ymd} {start_t}:00') |
|
132 |
+ end_dt = tc.string_to_utc_datetime(f'{current_ymd} {end_t}:00') |
|
133 |
+ if tc.utc_datetime(start_dt, minutes=60) < current_dt < tc.utc_datetime(end_dt, minutes=60): |
|
122 | 134 |
return f'{start_t}-{end_t}' |
123 | 135 |
return '' |
124 | 136 |
|
@@ -130,6 +142,9 @@ class IsolationPointUserInfo(BaseModelMixin): |
||
130 | 142 |
|
131 | 143 |
fields = JSONField(_('fields'), default=[], blank=True, null=True, help_text='字段信息') |
132 | 144 |
|
145 |
+ remark = JSONField(_('remark'), default=[], blank=True, null=True, help_text='备注') |
|
146 |
+ leave_at = models.DateTimeField(_('leave_at'), blank=True, null=True, help_text=_('离开时间')) |
|
147 |
+ |
|
133 | 148 |
class Meta: |
134 | 149 |
verbose_name = _('隔离点用户录入信息') |
135 | 150 |
verbose_name_plural = _('隔离点用户录入信息') |